package org.icy.core.setup.verification;

import org.icy.core.setup.VerificationResult;

public class MemoryVerification implements Verification {

	@Override
	public VerificationResult verify() {
		long mem = Runtime.getRuntime().maxMemory();
		if (mem > 256)
			return new VerificationResult(true, formatMem(mem), "Memory limit", null);
		return new VerificationResult(false, mem, "Memory limit", "Icy require at least 256MB of memory");
	}

	private String formatMem(long mem) {
		if (mem > 1024*1024)
			return mem/(1024*1024)+"M";
		if (mem > 1024)
			return mem/1024+"K";
		return mem+"";
	}

}
